var t = getApp();

Page({
    data: {
        active: 0,
        page: 1,
        last_page: 1,
        current_page: 1
    },
    onLoad: function(t) {},
    onChange: function(t) {
        this.setData({
            active: t.detail.index,
            current_page: 1,
            page: 1,
            last_page: 1,
            list: []
        }), this.getData();
    },
    onReady: function() {},
    onShow: function() {
        this.getData();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        if (!(this.data.current_page >= this.data.last_page)) {
            var t = this.data.page + 1;
            this.setData({
                page: t
            }), this.getMore();
        }
    },
    onShareAppMessage: function() {},
    getData: function() {
        var a = this, e = t.getNetAddresss("plugin.redpack-tool.frontend.rank.index");
        t._postNetWork({
            url: e,
            data: {
                page: this.data.page,
                rank_type: this.data.active + 1
            },
            success: function(t) {
                var e = t.data;
                console.log(e), 1 == e.result ? a.setData({
                    list: e.data.data,
                    current_page: e.data.current_page,
                    last_page: e.data.last_page
                }) : wx.showToast({
                    title: e.msg
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMore: function() {
        var a = this, e = t.getNetAddresss("plugin.redpack-tool.frontend.rank.index");
        t._postNetWork({
            url: e,
            data: {
                page: this.data.page,
                rank_type: this.data.active + 1
            },
            success: function(t) {
                var e = t.data;
                console.log(e), 1 == e.result ? a.setData({
                    list: a.data.list.concat(e.data.data),
                    current_page: e.data.current_page,
                    last_page: e.data.last_page
                }) : wx.showToast({
                    title: e.msg
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    }
});